package edu.cuit.avatar.handler;

import java.util.HashMap;
import java.util.Map;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/7/19 14:24
 */
public enum Command {
    INSERT('i'),
    DELETE('d'),
    UPDATE('u'),
    ALL('a'),
    FIND('f'),
    EXIT('e');

    private char shortCommand;
    private static Map<Character, Command> map;

    static {
        map = new HashMap<>();
        Command[] values = Command.values();
        for (Command command : values)
            map.put(command.shortCommand, command);
    }

    Command(char shortCommand){
        this.shortCommand = shortCommand;
    }

    public static Command getCommandByShortCharacter(char shortCommand){
        return map.get(shortCommand);
    }
}
